﻿package java_45;

import java.util.Scanner;

public class code090 {
    public static void main(String[] args) {
    	String[] musics = new String[]{"Islan","Ocean","pretty","sun"};
    	String[] newMusics = new String[musics.length+1];
    	String music="";
    	int index = musics.length;
    	System.out.println("插入前的数组为:");
    	for (int i = 0; i < musics.length; i++) {
			System.out.println(musics[i]+" ");
		}
    	for (int i = 0; i < musics.length; i++) {
			newMusics[i]=musics[i];
		}
    	Scanner input = new Scanner(System.in);
    	System.out.println("\n请输入歌名");
    	music= input.nextLine();
    	for (int i = 0; i < musics.length; i++) {
			if (musics[i].compareToIgnoreCase(music)>0) {
				index=i;
				break;
			}
		}
    for (int i = newMusics.length-1; i > index; i--) {
		newMusics[i]=newMusics[i-1];
	}
    newMusics[index]=music;
    System.out.println("插入后的数组为:");
    for (int i = 0; i < newMusics.length; i++) {
		System.out.println(newMusics[i]+" ");
	}
    }
}